class Admin::UsersController < AdminController
  
  def new
    @user = User.new
  end
 
  def create
    @user = User.new(params[:user])
    success = @user && @user.save
    flash[:notice] = success && @user.errors.empty? && @user.reload.activate! ? t(:user_created) : t(:error_user_creation)
    render :action => 'new'
  end

  destroy.wants.html { redirect_to :back }

  def update
    object
    success = @user.update_attributes(params[:user])
    flash[:notice] = success && @user.errors.empty? ? t(:user_updated) : t(:error_user_update)
    redirect_to :back
  end

  private

  def collection
    @users ||= User.all
  end

  def object
    @user ||= User.find(params[:id])
  end

  def model_name
    'user'
  end

end
